<?php
session_start();
include 'nav.inc.php';
include 'dbConn.php';
html_head('Neuen Verteiler hinzufügen');

echo("<link rel='stylesheet' type='text/css' href='styleVerteiler.css' media='all' />\n");
echo "<script type='text/javascript' href='verteiler.js'></script>";

menu();

echo("<div class='content'>\n");

echo "<form name='newList' action='".$_SERVER['SCRIPT_NAME']."' method='post' >\n";
echo "\t<fieldset>
  <legend>Neue Verteilerliste</legend>
  <ol class='clearfix'>
    <li>
      <label for='title'>Titel:</label>
      <input type='text' name='title' id='Titel' value='' onfocus='if (submit.value == \"Eingetragen\"){ colorReset();}'/>
    </li>
    <li>
      <label for='email'>E-Mail:</label>
      <input type='text' name='email' id='email' value='' onfocus='if (submit.value == \"Eingetragen\"){ colorReset();}'/>
    </li>
    <li>
      <label for='content'>Kommentar (z.B. gedacht für):</label>
<textarea cols='32' rows='7' name='content' id='content' onfocus='if (submit.value == \"Eingetragen\"){ colorReset();}'></textarea>
    </li>
    <li class='last'>
      <input type='submit' name='submit' id='submit' value='Eintragen' onfocus='if (submit.value == \"Eingetragen\"){ colorReset();}''/>
    </li>
  </ol>
  </fieldset>";
echo "\t</form>\n";

if (isset($_REQUEST['submit']))
{
	$ret = $dbVerteiler->insertNewList($_REQUEST['title'],$_REQUEST['content'],$_REQUEST['email']);
	switch ($ret)
	{
		case 3:
			echo "Eine Liste mit diesem Titel ist bereits vorhanden.";
			break;
		case 2:
			echo "Die Adresse ".$addresse." wird bereits verwendet.";
			break;
		default:
			echo 
			"
			<div style='margin-left:220px;'><h3>Liste erfolgreich eingetragen!</h3></div>
			<br/>";

			echo "<script language=javascript>colorswitch('submit');</script>";
			break;
	}
}
echo "</div>";
?>
